$(function(){
	//初始化诊断记录
	initdiagnosisRecord();
	
	//无诊断记录 点击 马上咨询
	$("#diagnosis").on("click",function(){
		location.href="../../html/onlineContinuation/online-continuation.html"
	});
	
	
	
	function initdiagnosisRecord(){
		var archivesId= utilModule.getQueryString("archivesid");
		console.log(archivesId);
		var param = {"uid":archivesId,"currentPage":1,"pageSize":999};
		diagnosisRecordModule.diagnosisArchivesModule(param,function(callBack){
			console.log(callBack);
			var result = callBack.listPrescription;
			console.log(result);
			if(result.length){
				$(".nodiagnosisRecord").hide();
				$(".listing").show();
				for(var tkey in result) {
		           var infor = result[tkey];
		           var showHtml = "";
		           showHtml+="<li v=\"" + infor.pid + "\">";
				   showHtml+="<p class=\"diagnosisresult\">诊断结果：<span>"+infor.diagnosis+"</span></p>";
				   showHtml+="<div class=\"lists\">";
		           showHtml+="<p class=\"diagnosistime\">诊断日期：<span>"+infor.createtime+"</span></p>";  
		           var $told = infor.told;
				   if($told) {
					   showHtml+="<p class=\"diagnosisrecord\">医　　嘱：<span>"+$told+"</span></p>";
				   }else{
				   	   showHtml+="<p class=\"diagnosisrecord\">医　　嘱：<span>无</span></p>";
				   }
				   
				
		           showHtml+="</div>";
		           showHtml+="</li>";
		           $(".listing ul").append(showHtml); 
				}
				//跳转对应的 诊断 详情页面
			 	$(".listing ul li").on("touchstart",function(){
	             	var diagnosisrecordNum = $(this).attr("v");
	             	sessionStorage.setItem("diagnosisrecordNum",diagnosisrecordNum);
	          		location.href="deagnostic-details.html?diagnosisRecord="+diagnosisrecordNum;
             	});
			}
		});
	}
	$(".html-loding").hide();
	
	/*function queryMyDoctorList() {
		var params = {
			"patientid":USERID	
		};
		userCenterModule.queryMyDoctorList(params, function(callBack) {
			console.log(callBack);
			if(callBack.length){
				if(callBack.length==1){
					var infor = callBack[0].doctor;
					if(infor.isfinevisit==0){
						location.href="../../html/doctor/doctor-details.html?doctorid="+infor.id
					}else{
						location.href="../../html/doctor/make-doctor.html";
					}
				}
				if(callBack.length==2){
					for(i=0;i<callBack.length;i++){
						var infor = callBack[i].doctor;
						if(infor.isfinevisit==0){
							location.href="../../html/doctor/doctor-details.html?doctorid="+infor.id
						}	
					}
				}
			}else{
				location.href="../../html/doctor/make-doctor.html";
			}
		});
	}*/
});










